import type {
  GetCodeData,
  GetCodeParams,
  PostLoginData,
  PostLoginParams,
  PostUploadData,
} from '@/types/common'
import type {  PostLoginPasswordParams,PostLoginPasswordData } from '@/types/login'
import { request, service } from '@/utils/request'

/**
 * 登录--密码登录
 * @param data 手机号、密码
 * @returns
 */
export const postLoginPasswordAPI = (data: PostLoginPasswordParams) => {
  return request<PostLoginPasswordData>('/login/password', 'POST', data)
}

/**
 * 获取手机验证码
 * @param params 手机号、验证码类型
 * @returns
 */
export const getCodeAPI = (params: GetCodeParams) => {
  return request<GetCodeData>('/code', 'GET', params)
}

/**
 * 登录--手机验证码登录
 * @param data 手机号、验证码
 * @returns
 */
export const postLoginAPI = (data: PostLoginParams) => {
  return request<PostLoginData>('/login', 'POST', data)
}

//兼容性上传图片
export const uploadImageAPI = (filePath:string) => {
  return service.upload('/upload', {
    name: 'file',
    filePath: filePath,
  })
}

//上传图片
export const postUploadAPI = (filePath:string) => {
  return request<PostUploadData>('/upload', 'UPLOAD',{},{name:'file',filePath} )
}
